package com.hxtec.polaris.commons.tasks;

import com.hxtec.polaris.commons.constant.GlobalVar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;

/**
 * @Describtion 项目初始化执行任务
 * @Author yonyong
 * @Date 2019/12/20 15:15
 * @Version 1.0.0
 **/
@Component
@Transactional
@Order(value = 1)
public class InitTask implements CommandLineRunner {

    private  static final Logger logger = LoggerFactory.getLogger(InitTask.class);

    @Override
    public void run(String... args){
        File file = new File(GlobalVar.UPLOAD_BASE_PATH);
        if (!file.exists()) {
            try{
                file.mkdirs();
                logger.info("当前发布项目下，没有对应目录！已创建"+GlobalVar.UPLOAD_BASE_PATH);
            }catch (Exception e){
                logger.info("当前发布项目下，没有对应目录！目录创建失败！目录名称"+GlobalVar.UPLOAD_BASE_PATH);
            }
        }
    }
}
